package dao.wx;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import dao.BaseDAO;
import dao.RowMapper;
import entity.OrderForm;

public class OrderDao extends BaseDAO{
	public List<OrderForm> orderquery(int id,int curpage,int pagesize){
		int start=(curpage-1)*pagesize;
		String sql="select * from tb_oyder_form where member_id=? limit ?,?";
		List<OrderForm> list=executeQuery(sql, new RowMapper<OrderForm>() {
			@Override
			public OrderForm mapper(ResultSet rs) throws SQLException {
				OrderForm one=new OrderForm(rs.getInt(1),
											rs.getTimestamp(2),
											rs.getString(3),
											rs.getDouble(4),
											rs.getDouble(5),
											rs.getString(6),
											rs.getString(7),
											rs.getString(8),
											rs.getTimestamp(9)
						);
				return one;
			}
		},id,start,pagesize);
		return list;
	}

	public int countorder(int id) {
		String sql="select count(*) from tb_oyder_form where member_id=?";
		int a=get(sql, new RowMapper<Integer>() {
			@Override
			public Integer mapper(ResultSet rs) throws SQLException {
				return rs.getInt(1);
			}
		}, id);
		return a;
	}
	public void orderdelete(int id) {
		String sql="delete from tb_oyder_form where oyder_id=?";
		executeUpdate(sql, id);
	}
}
